package cn.edu.neusoft.wuguangsheng.flowerimpression.activity;

import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

import cn.edu.neusoft.wuguangsheng.flowerimpression.R;
import cn.edu.neusoft.wuguangsheng.flowerimpression.adapter.EmptyRecyclerView;
import cn.edu.neusoft.wuguangsheng.flowerimpression.adapter.ShopMyCommentAdapter;
import cn.edu.neusoft.wuguangsheng.flowerimpression.bean.GoodsCommentBean;
import cn.edu.neusoft.wuguangsheng.flowerimpression.listener.ListListener;
import cn.edu.neusoft.wuguangsheng.flowerimpression.model.GetMyOrderCommentListModel;

public class ShopMyCommentActivity extends BaseActivity implements View.OnClickListener {
     ImageView shopmycomment_fh;
     EmptyRecyclerView shopmycomment_rv;
     View shopmycomment_ev;
     List<GoodsCommentBean> items;
     private boolean up = false;
     TextView tv_message;

    @Override
    void initView() {
        setLayout_file(R.layout.activity_shop_my_comment);
        shopmycomment_fh = (ImageView)findViewById(R.id.shopmycomment_fh);
        shopmycomment_rv = (EmptyRecyclerView)findViewById(R.id.shopmycomment_rv);
        shopmycomment_ev = (View) findViewById(R.id.shopmycomment_ev);
        tv_message = (TextView)findViewById(R.id.tv_message);

        GetMyOrderCommentListModel getMyOrderCommentListModel = new GetMyOrderCommentListModel();
        getMyOrderCommentListModel.getMyOrderCommentList(getid(), new ListListener<GoodsCommentBean>() {
            @Override
            public void onResponse(List<GoodsCommentBean> list) {
                LinearLayoutManager linearLayoutManager=new LinearLayoutManager(ShopMyCommentActivity.this);
                linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
                shopmycomment_rv.setLayoutManager(linearLayoutManager);
                items=list;
                ShopMyCommentAdapter shopMyCommentAdapter=new ShopMyCommentAdapter(ShopMyCommentActivity.this,items,R.layout.myordercomment_item);
                shopmycomment_rv.setAdapter(shopMyCommentAdapter);
                shopmycomment_rv.setItemAnimator(new DefaultItemAnimator());
                tv_message.setText("你还没有任何订单评价！");
                shopmycomment_rv.setEmptyView(shopmycomment_ev);

            }

            @Override
            public void onFail(String msg) {

            }
        });
    }

    @Override
    void initEvent() {
        shopmycomment_fh.setOnClickListener(this);

    }

    @Override
    void initDate() {

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.shopmycomment_fh:
                finish();
                break;
        }
    }
    @Override
    public void onPause() {
        super.onPause();
        up = true;
    }

    @Override
    public void onResume() {
        super.onResume();
        if (up) {
            initView();
            initEvent();
            initDate();
            up = false;
        }
    }
}
